package com.ehsy.service;

import com.dtflys.forest.annotation.*;
import com.dtflys.forest.callback.OnError;
import com.dtflys.forest.callback.OnSuccess;
import com.ehsy.common.ResponseVo;
import com.ehsy.model.UserInfo;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

/**
 * @author YanZhen_Li
 * @version 1.0
 * @title AsynService
 * @description
 * @create 2024/6/19 11:54
 */
@Component
@Address(host = "127.0.0.1", port = "8080")
public interface AsynService {
    /**
     * 模拟异步请求，其中的async为true的时候表示为异步请求，为false表示为同步请求
     */
    @Get(
            url = "/test/request/json/body/{sleep}",
            async = true
    )
    ResponseVo<UserInfo> test1(@Query UserInfo user, @Var("sleep") int sleep);

    @Get(
            url = "/test/request/json/body/{sleep}",
            async = true
    )
    void test2(@Query UserInfo user, @Var("sleep") int sleep, OnSuccess<ResponseVo<UserInfo>> onSuccess, OnError onError);

    @Request(
            url = "/test/request/json/body/{sleep}",
            async = true
    )
    Future<ResponseVo<UserInfo>> test3(@Query UserInfo user, @Var("sleep") int sleep);

}
